/*
 * Vlabs Biological Web Elemments
 *
 * Copyright (c) 2009 Victor de la Torre (vdelatorre@cnio.es)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 * 
 * http://code.google.com/p/bwe/ 
 *
 */
var filesadded="" //list of files already added

function importFile(filename, filetype){
 if (filesadded.indexOf("["+filename+"]")==-1){
  loadjscssfile(filename, filetype)
  filesadded+="["+filename+"]" //List of files added in the form "[filename1],[filename2],etc"
 }
} 
 
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined"){

 	 document.getElementsByTagName("head")[0].insertBefore(fileref,bweStartNode);
 }
} 

var bweBase	= 'http://ubio.bioinfo.cnio.es/biotools/bwe/'
/* var bweBase	= 'http://localhost/bwe/'; */
var bweStartNode =  document.getElementById("bwel");

//jQuery
if (typeof jQuery == 'undefined') {
	importFile("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js", "js");       
}

//css
importFile(bweBase+"css/bwe.css", "css");
importFile(bweBase+"ext/jquery-ui-1.7.2.custom/css/custom-theme/jquery-ui-1.7.2.custom.css", "css");
importFile(bweBase+"ext/OpenLayers-2.8/theme/default/style.css", "css");
importFile(bweBase+"ext/jScrollPane.css", "css");

//jQuery UI
if(!jQuery.ui) {
	importFile(bweBase+"ext/jquery-ui-1.7.2.custom/js/jquery-ui-1.7.2.custom.min.js", "js");
}
//ext
importFile(bweBase+"ext/webtoolkit.base64.js", "js");
importFile(bweBase+"ext/OpenLayers-2.8/OpenLayers.js", "js");
importFile(bweBase+"ext/genome-browser-0.31/javascript/Genomic.js", "js");
importFile(bweBase+"ext/genome-browser-0.31/javascript/opengenes.js", "js");
importFile(bweBase+"ext/jScrollPane.js", "js");

//classes
importFile(bweBase+"core.js", "js");
importFile(bweBase+"ihop.js", "js");
importFile(bweBase+"sequence.js", "js");
importFile(bweBase+"madasmap.js", "js");
importFile(bweBase+"fragkb.js", "js");
